<template>
  <div id="cart">
    <nav-bar class="nav-bar">
      <div slot="center">购物车({{cartLength}})</div>
    </nav-bar>
    <cart-list :cart-list="cartList" />
    <cart-bottom-bar />
  </div>
</template>

<script>
  import NavBar from 'components/common/navBar/NavBar'
  import CartList from './childComps/CartList'
  import CartBottomBar from './childComps/CartBottomBar'

  import {mapGetters} from 'vuex'

  export default {
    name: "Cart",
    components: {
      NavBar,
      CartList,
      CartBottomBar
    },
    data(){
      return{
      }
    },
    computed: {
      // cartLength(){
      //   // return this.$store.state.cartList.length
      //   return this.$store.getters.cartLength
      // }
      //两种语法
      ...mapGetters(['cartLength', 'cartList'])

      // ...mapGetters({
      //   length: 'cartLength',
      //   list: 'cartList'
      // })

    }
  }
</script>

<style scoped>
  #cart {
    /*position: relative;*/
    height: 100vh;
  }
  .nav-bar {
    background-color: var(--color-tint);
    font-weight: 700;
    color: #fff;
  }
  .cart-list {
    position: absolute;
    top: 44px;
    bottom: 49px;
    width: 100%;
  }
</style>
